<%@ page pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <c:url var="base" value="/"/>
    <base href="${base}">
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<jsp:useBean id="teacher" scope="request" type="com.entity.Teacher"/>
<jsp:useBean id="titles" scope="request" type="java.util.List<com.entity.Title>"/>
<jsp:useBean id="courses" scope="request" type="java.util.List<com.entity.Course>"/>
<form action="updateteacher" method="post">
    <label>
        用户：
        <input name="name" value="${teacher.name}">
    </label>
    <br>
    注册时间：<fmt:formatDate pattern="yyyy-MM-dd HH:mm" value="${teacher.insertDate}" />
    <br>
    职称：
    <select name="tit">
        <c:forEach items="${titles}" var="t">
            <c:set var="tt" value="" />
            <c:if test="${t.id == teacher.title.id}">
                <c:set var="tt" value="selected" />
            </c:if>
            <option ${tt} value="${t.id}">${t.name}</option>
        </c:forEach>
    </select>
    <br>
    授课：
    <ul>
        <c:forEach items="${courses}" var="c">
            <c:set var="ci" value="" />
            <c:forEach items="${teacher.courses}" var="tc">
                <c:if test="${tc.id == c.id}">
                    <c:set var="ci" value="checked" />
                </c:if>
            </c:forEach>
            <li><label>
                <input type="checkbox" ${ci} name="cid" value="${c.id}">
            </label>${c.name}</li>
        </c:forEach>
    </ul>
    <button type="submit">提交</button>
    <button type="reset">重置</button>
</form>
</body>
</html>
